﻿//
// 请注意：bbsmax 不是一个免费产品，源代码仅限用于学习，禁止用于商业站点或者其他商业用途
// 如果您要将bbsmax用于商业用途，需要从官方购买商业授权，得到授权后可以基于源代码二次开发
//
// 版权所有 厦门麦斯网络科技有限公司
// 公司网站 www.bbsmax.com
//

using System;
using System.IO;
using System.Text;
using System.Web.UI;
using System.Collections.Generic;

namespace MaxLabs.WebEngine
{
	public class AjaxPanelWriter : TextWriter
	{
		private string m_AjaxPanelID;
		private StringBuilder m_Content;
		private HtmlTextWriter m_InnerWriter;

		public AjaxPanelWriter(string ajaxPanelID, HtmlTextWriter innerWriter) : base(null)
		{
			m_AjaxPanelID = ajaxPanelID;
			m_InnerWriter = innerWriter;
			m_Content = new StringBuilder(10);
		}

		public override void Write(char value)
		{
			m_Content.Append(value);
		}

		protected override void Dispose(bool disposing)
		{
			m_InnerWriter.Write(m_AjaxPanelID);
			m_InnerWriter.Write("|");
			m_InnerWriter.Write(m_Content.Length);
			m_InnerWriter.Write("|");
			m_InnerWriter.Write(m_Content.ToString());
			m_InnerWriter.Write("|");

			m_InnerWriter = null;
			m_Content = null;

			base.Dispose(disposing);
		}

		public override Encoding Encoding
		{
			get { return Encoding.UTF8; }
		}
	}
}